package org.example.index;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.shiro.service.SysPasswordService;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysNoticeMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import org.example.contract.domain.Contract;
import org.example.contract.mapper.ContractMapper;
import org.example.partner.domain.Partner;
import org.example.partner.domain.TenementInfo;
import org.example.partner.mapper.PartnerMapper;
import org.example.partner.mapper.TenementInfoMapper;
import org.example.partner.service.IPartnerService;
import org.example.utils.Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 合作伙伴Service业务层处理
 *
 * @author 小孟微信：xiaomengcode
 * @date 2024-04-11
 */
@Service
public class IndexServiceImpl implements IIndexService
{

    @Autowired
    private SysNoticeMapper noticeMapper;

    @Autowired
    private SysDeptMapper deptMapper;

    @Override
    public List<SysNotice> selectNoticeList(SysNotice notice) {
        return noticeMapper.selectNoticeList(notice);
    }

    @Override
    public SysDept dept(SysDept dept) {
        SysDept deptDB = ShiroUtils.getSysUser().getDept();
        deptDB.setParentName(deptDB.getDeptName());
        String[] strArray = Convert.toStrArray(deptDB.getAncestors());
        if(strArray.length==3){
            SysDept parentDept = deptMapper.selectDeptById(deptDB.getParentId());
            deptDB.setParentName(parentDept.getDeptName());
        }
        return deptDB;
    }
}
